import 'package:json_annotation/json_annotation.dart';
import 'package:mall/core/models/jump_type.dart';

part 'store_index.g.dart';

@JsonSerializable()
class StoreIndex {
  @JsonKey(name: "STORE_BASE_INFO")
  final Store store;
  @JsonKey(defaultValue: [], name: "NAVIGATOR")
  final List<Link> navigator;
  @JsonKey(defaultValue: [], name: "BANNER_LIST")
  final List<Link> bannerList;
  @JsonKey(defaultValue: [], name: "NEWS_LIST")
  final List<Link> newsList;
  @JsonKey(defaultValue: [], name: "HOT_PRODUCT_LIST")
  final List<Link> hotList;
  @JsonKey(defaultValue: [])
  final List<Link> recommendList;
  @JsonKey(defaultValue: [], name: "FLOOR_LIST")
  final List<Floor> floorList;
  @JsonKey(defaultValue: [], name: "PIN_GOU_LIST")
  final List<Floor> pinGouList;
  @JsonKey(defaultValue: [], name: "QIANG_GOU_LIST")
  final List<Floor> qiangGouList;
  @JsonKey(defaultValue: [], name: "RECOMMEND_STORES")
  final List<Floor> recommendStoreList;

  StoreIndex(
    this.store,
    this.navigator,
    this.bannerList,
    this.newsList,
    this.hotList,
    this.recommendList,
    this.floorList,
    this.pinGouList,
    this.qiangGouList,
    this.recommendStoreList,
  );

  factory StoreIndex.fromJson(Map<String, dynamic> json) => _$StoreIndexFromJson(json);

  Map<String, dynamic> toJson() => _$StoreIndexToJson(this);
}

@JsonSerializable()
class Store {
  final int id;
  final String name;
  final String logoUrl;

  Store(this.id, this.name, this.logoUrl);

  factory Store.fromJson(Map<String, dynamic> json) => _$StoreFromJson(json);

  Map<String, dynamic> toJson() => _$StoreToJson(this);
}

@JsonSerializable()
class Floor {
  final int id; // 10,
  final String title; // "热卖抢购",
  final int sort; // 0,
  final String extend; // null,
  final String versionType; // "MOBILE_APP",
  final String displayType; // "QIANG_GOU",
  final double productPrice; // 价格
  final String priceAccountType;
  final DateTime pinGouStartTime; // null,
  final int maxSeconds; // 0,
  final int linkStoreId; // 0,
  final String linkStoreName; // null,
  final String linkStoreLogoUrl; // null,
  final String linkStoreType; // "",
  final int linkStoreAreaId; // 0,
  final String linkStoreAreaName; // null,
  final String linkStoreAreaType; // "",
  final int groupPurchaseTeamId;
  final int groupPurchaseParamId;
  final String businessType;
  final List<Link> floorLinks; // [],
  @JsonKey(defaultValue: [])
  final List<Link> productLinks;

  Floor(
    this.id,
    this.title,
    this.sort,
    this.extend,
    this.versionType,
    this.displayType,
    this.productPrice,
    this.priceAccountType,
    this.pinGouStartTime,
    this.maxSeconds,
    this.linkStoreId,
    this.linkStoreName,
    this.linkStoreLogoUrl,
    this.linkStoreType,
    this.linkStoreAreaId,
    this.linkStoreAreaName,
    this.linkStoreAreaType,
    this.groupPurchaseTeamId,
    this.groupPurchaseParamId,
    this.businessType,
    this.floorLinks,
    this.productLinks,
  );

  factory Floor.fromJson(Map<String, dynamic> json) => _$FloorFromJson(json);

  Map<String, dynamic> toJson() => _$FloorToJson(this);
}

@JsonSerializable()
class Link {
  final int id; // 82,
  final String title; // "e健联",
  final String content; // null,
  final String link; // "storeId=1",
  final String image; // "http://26674r3t03.51vie3f5-48fa-9e29-90340d86c162_20201115134104",
  final String extend; // "",
  final int sort; // 100,
  final String type; // "NAVIGATOR",
  final String displayType; // "IMAGE",
  final String versionType; // "MOBILE_APP",
  final JumpType jumpType; // "JUMP_IN_STORE",
  final int modelInAreaId; // null,
  final String createTime; // "2020-11-15 14:40:46",
  final String creatorName; // "sysadmin",
  final int storeId; // null,
  final int storeAreaId; // null,
  final DateTime startTime; // null,
  final DateTime endTime; // null,
  final DateTime serverTime; // "2020-11-16 00:27:28"

  Link(
    this.id,
    this.title,
    this.content,
    this.link,
    this.image,
    this.extend,
    this.sort,
    this.type,
    this.displayType,
    this.versionType,
    this.jumpType,
    this.modelInAreaId,
    this.createTime,
    this.creatorName,
    this.storeId,
    this.storeAreaId,
    this.startTime,
    this.endTime,
    this.serverTime,
  );

  factory Link.fromJson(Map<String, dynamic> json) => _$LinkFromJson(json);

  Map<String, dynamic> toJson() => _$LinkToJson(this);
}
